package thread.example;

import java.sql.DriverManager;
import java.util.Vector;

/**
 * Created by simod on 2019/12/21
 */
public class System12306 {
    public static DriverManager out;
    private Vector<Ticket> tickets = new Vector<>();
    private static System12306 system12306 = new System12306();

    public static System12306 getInstance() {
        return system12306;
    }

    {
        for (int i = 0; i < 50; i++) {
            tickets.add(new Ticket("北京" + i, "上海" + i, 34f));
        }
    }

    private System12306() {
    }

    public Ticket getTicket() {
        try {
            return tickets.remove(0);
        } catch (Exception e) {
            return null;
        }
    }
}
